gdk/dnd: Don't use default display when getting cursor
authorJonas Ådahl <jadahl@gmail.com>
Tue, 26 Apr 2016 07:31:33 +0000 (15:31 +0800)
committerJonas Ådahl <jadahl@gmail.com>
Tue, 26 Apr 2016 15:03:24 +0000 (23:03 +0800)
Always associate a drag context with a GdkDisplay and use that when
getting a cursor for a given action.

If we don't do this, dragging on a window that doesn't use the default
display will make us use cursors from the wrong display.

https://bugzilla.gnome.org/show_bug.cgi?id=765565

gdk/broadway/gdkdnd-broadway.c
gdk/gdkdnd.c
gdk/gdkdndprivate.h
gdk/quartz/GdkQuartzNSWindow.c
gdk/quartz/gdkdnd-quartz.c
gdk/wayland/gdkdevice-wayland.c
gdk/wayland/gdkdnd-wayland.c
gdk/wayland/gdkprivate-wayland.h
gdk/win32/gdkdnd-win32.c
gdk/x11/gdkdnd-x11.c

index 042a0cd65b5fe6e880affb71038e0600ae9fb5ff..7c5fffeb6aea66d36de1c54b2ad4cdf004707102 100644 (file)
@@ -98,6 +98,7 @@ _gdk_broadway_window_drag_begin (GdkWindow *window,
 
   new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT,
                              NULL);
+  new_context->display = gdk_window_get_display (window);
 
   return new_context;
 }
index a1e52c2b2e9dab8ae6f340254f1d55de2f053a7b..163a705ee05ce809592e0cda3bbcdc99a69303a5 100644 (file)
@@ -753,7 +753,8 @@ gdk_drag_context_handle_source_event (GdkEvent *event)
 }
 
 GdkCursor *
-gdk_drag_get_cursor (GdkDragAction action)
+gdk_drag_get_cursor (GdkDragContext *context,
+                     GdkDragAction   action)
 {
   gint i;
 
@@ -762,7 +763,7 @@ gdk_drag_get_cursor (GdkDragAction action)
       break;
 
   if (drag_cursors[i].cursor == NULL)
-    drag_cursors[i].cursor = gdk_cursor_new_from_name (gdk_display_get_default (),
+    drag_cursors[i].cursor = gdk_cursor_new_from_name (context->display,
                                                        drag_cursors[i].name);
   return drag_cursors[i].cursor;
 }
index 283dba2b85430881a68d7afcc7958b509d560483..d37ec67ab72ce927db7ab510998c66b8e34e06ec 100644 (file)
@@ -94,6 +94,8 @@ struct _GdkDragContext {
   /*< private >*/
   GdkDragProtocol protocol;
 
+  GdkDisplay *display;
+
   gboolean is_source;
   GdkWindow *source_window;
   GdkWindow *dest_window;
@@ -119,7 +121,8 @@ void     gdk_drag_context_cancel              (GdkDragContext      *context,
                                                GdkDragCancelReason  reason);
 gboolean gdk_drag_context_handle_source_event (GdkEvent *event);
 gboolean gdk_drag_context_handle_dest_event   (GdkEvent *event);
-GdkCursor * gdk_drag_get_cursor (GdkDragAction action);
+GdkCursor * gdk_drag_get_cursor               (GdkDragContext *context,
+                                               GdkDragAction   action);
 
 G_END_DECLS
 
index e45c632aa841b6de9fc8b1b0942d9f462e417457..5a99411c6e940059b70bb452a0aa85094e232175 100644 (file)
@@ -587,6 +587,8 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
 
   window = [[self contentView] gdkWindow];
 
+  current_context->display = gdk_window_get_display (window);
+
   device_manager = gdk_display_get_device_manager (gdk_display_get_default ());
   gdk_drag_context_set_device (current_context,
                                gdk_device_manager_get_client_pointer (device_manager));
index 0a38cd892eabf84be5c13358874ef968c871695c..15b6fed3191c97cc3df461d530cb14f4ccbbac28 100644 (file)
@@ -44,6 +44,7 @@ _gdk_quartz_window_drag_begin (GdkWindow *window,
   /* Create fake context */
   _gdk_quartz_drag_source_context = g_object_new (GDK_TYPE_QUARTZ_DRAG_CONTEXT,
                                                   NULL);
+  _gdk_quartz_drag_source_context->display = gdk_window_get_display (window);
   _gdk_quartz_drag_source_context->is_source = TRUE;
 
   _gdk_quartz_drag_source_context->source_window = window;
index c220d2b82b6065f004a079e39ffaf13f0b887434..e3f7fac7e244b527663a88a3efc60090752ac086 100644 (file)
@@ -3988,7 +3988,8 @@ _gdk_wayland_device_manager_add_seat (GdkDeviceManager *device_manager,
   seat->data_device =
     wl_data_device_manager_get_data_device (display_wayland->data_device_manager,
                                             seat->wl_seat);
-  seat->drop_context = _gdk_wayland_drop_context_new (seat->data_device);
+  seat->drop_context = _gdk_wayland_drop_context_new (display,
+                                                      seat->data_device);
   wl_data_device_add_listener (seat->data_device,
                                &data_device_listener, seat);
 
index 7bb0c6186d9fdc94ea0b157cc2d1d2dd264c6a6b..adc33a4bc27ebcd911dd3f9d5381fdeb7ce93043 100644 (file)
@@ -427,7 +427,7 @@ gdk_wayland_drag_context_action_changed (GdkDragContext *context,
 {
   GdkCursor *cursor;
 
-  cursor = gdk_drag_get_cursor (action);
+  cursor = gdk_drag_get_cursor (context, action);
   gdk_drag_context_set_cursor (context, cursor);
 }
 
@@ -528,6 +528,7 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
 
   context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, NULL);
   context = GDK_DRAG_CONTEXT (context_wayland);
+  context->display = gdk_window_get_display (window);
   context->source_window = g_object_ref (window);
   context->is_source = TRUE;
   context->targets = g_list_copy (targets);
@@ -552,13 +553,15 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
 }
 
 GdkDragContext *
-_gdk_wayland_drop_context_new (struct wl_data_device *data_device)
+_gdk_wayland_drop_context_new (GdkDisplay            *display,
+                               struct wl_data_device *data_device)
 {
   GdkWaylandDragContext *context_wayland;
   GdkDragContext *context;
 
   context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, NULL);
   context = GDK_DRAG_CONTEXT (context_wayland);
+  context->display = display;
   context->is_source = FALSE;
 
   return context;
index eb93047f9626fd843fb4371a6aa6b6a397abd679..81770f6640761190796f0715b9e1286960f25473 100644 (file)
@@ -109,7 +109,8 @@ GdkDragContext *_gdk_wayland_window_drag_begin (GdkWindow *window,
 void            _gdk_wayland_window_offset_next_wl_buffer (GdkWindow *window,
                                                            int        x,
                                                            int        y);
-GdkDragContext * _gdk_wayland_drop_context_new (struct wl_data_device *data_device);
+GdkDragContext * _gdk_wayland_drop_context_new (GdkDisplay            *display,
+                                                struct wl_data_device *data_device);
 void _gdk_wayland_drag_context_set_source_window (GdkDragContext *context,
                                                   GdkWindow      *window);
 void _gdk_wayland_drag_context_set_dest_window (GdkDragContext *context,
index d012463a96673d636340d5f2afff15cca85ac0bc..cec3dcc763963f1d7cabbc987f98553dc6044033 100644 (file)
@@ -182,6 +182,7 @@ gdk_drag_context_new (GdkDisplay *display)
 
   context_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT, NULL);
   context = GDK_DRAG_CONTEXT(context_win32);
+  context->display = display;
 
   gdk_drag_context_set_device (context, gdk_seat_get_pointer (gdk_display_get_default_seat (display)));
 
index c2a69193d2e3b639e30f12e863b4bf368529a48e..3d25ea2734a8c5a304ae3c28d7b4906d8779d03d 100644 (file)
@@ -1705,6 +1705,7 @@ xdnd_enter_filter (GdkXEvent *xev,
   context_x11 = (GdkX11DragContext *)g_object_new (GDK_TYPE_X11_DRAG_CONTEXT, NULL);
   context = (GdkDragContext *)context_x11;
 
+  context->display = display;
   context->protocol = GDK_DRAG_PROTO_XDND;
   context_x11->version = version;
 
@@ -2020,6 +2021,7 @@ _gdk_x11_window_drag_begin (GdkWindow *window,
 
   context = (GdkDragContext *) g_object_new (GDK_TYPE_X11_DRAG_CONTEXT, NULL);
 
+  context->display = gdk_window_get_display (window);
   context->is_source = TRUE;
   context->source_window = window;
   g_object_ref (window);
@@ -3132,6 +3134,6 @@ gdk_x11_drag_context_action_changed (GdkDragContext *context,
 {
   GdkCursor *cursor;
 
-  cursor = gdk_drag_get_cursor (action);
+  cursor = gdk_drag_get_cursor (context, action);
   gdk_drag_context_set_cursor (context, cursor);
 }